package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteKingdeeService;
import com.ruoyi.system.api.domain.EmpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

/**
 * 文件服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteKingdeeFallbackFactory implements FallbackFactory<RemoteKingdeeService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteKingdeeFallbackFactory.class);

    @Override
    public RemoteKingdeeService create(Throwable throwable)
    {
        log.error("金蝶服务调用失败:{}", throwable.getMessage());
        return new RemoteKingdeeService()
        {
            @Override
            public void saveMaterialIncase(@RequestParam("approveDate") String approveDate)
            {

            }

            @Override
            public void saveMaterialTransferin(@RequestParam("approveDate") String approveDate)
            {
//                return R.fail("文件入库失败:" + throwable.getMessage());
            }

            @Override
            public void saveMaterialTransferout(@RequestParam("approveDate") String approveDate)
            {

            }

            @Override
            public R<List<EmpResponse>> getEmpByIdCard(@RequestParam("idcard") String idcard) {
                return R.fail("上传文件失败:" + throwable.getMessage());
            }

            @Override
            public void saveStapByStapcode(String stapCode) {

            }
        };
    }
}
